import http from '../util/request.js'
export default {
    add:(obj)=>{
        return http({
            url:'/api/post/add',
            method:'post',
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    edit:(obj)=>{
        return http({
            url:'/api/post',
            method:'put',
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    del:(id)=>{
        return http({
            url:'/api/post/'+id,
            method:'delete'
        });
    },
    delete:(id)=>{
        return http({
            url:'/api/post/del/'+id,
            method:'delete'
        });
    },
    //传表单参数
    page:(obj)=>{
        return http({
            url:'/api/post/page',
            method:'get',
            params:obj
        });
    },
    getPostsByUser:(id)=>{
        return http({
            url:'/api/post/users/'+id+'/posts',
            method:'get'
        });
    },
    listBytype:(id)=>{
        return http({
            url:'/api/post/type/'+id,
            method:'get',
        })
    }
}